import Vue, {h} from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        //token: ''
        hasRoutes: false
    },
    getters: {
        GET_TOKEN: state => {
            return sessionStorage.getItem('token')
            // return state.token;
        },
        GET_MENU_LIST: state => {
            return JSON.parse(sessionStorage.getItem('menuList'))
        },
        GET_USERINFO: state => {
            return JSON.parse(sessionStorage.getItem('currentUser'))
        }
    },
    mutations: {
        SET_TOKEN: (state, token) => {
            // state.token = token;
            sessionStorage.setItem('token', token)
        },
        SET_MENU_LIST: (state, menuList) => {
            sessionStorage.setItem('menuList', JSON.stringify(menuList))
            console.log("111" + JSON.parse(sessionStorage.getItem('menuList')))
        },
        SET_USER_INFO: (state, currentUser) => {
            sessionStorage.setItem('currentUser', JSON.stringify(currentUser))
        },
        SET_ROUTER_STATE(state,hasRoutes){
            state.hasRoutes = hasRoutes
        }
    },
    actions: {},
    modules: {}
})
